package com.building18.mapper;

import com.building18.pojo.Building;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BuildingMapper {
    @Select("select * from building_info")
   List<Building> selectBuilding();

    @Insert("insert into building_info(building_id, building_name, location, remark) values(default, #{buildingName}, #{location}, #{remark})")
    Integer addBuilding(Building building);

    @Delete("delete from building_info where building_id = #{id}")
    Integer deleteBuildingById(Integer id);

    @Update("update building_info set building_name = #{buildingName}, location = #{location}, remark = #{remark} where building_id = #{buildingId}")
    Integer updateBuilding(Building building);

    List<Building> selectBuildingByName(String name);

    @Select("select count(*) from house_info where building_id = #{id}")
    Integer countHouseByBuildingId(Integer id);

    Integer deleteBuildingByIds(@Param("ids") List<Integer> ids);

    @Select("select building_id, building_name from building_info")
    List<Building> selectBuildingIdAndName();
}
